home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / vlib250.zip / DEMOPROC.C < prev    next >
C/C++ Source or Header  |  1994-11-09  |  45KB  |  1,684 lines

  1. #include <windows.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include "visualib.h"
  5. #include "modellib.h"
  6. #include "vlibdemo.h"
  7. #include "demoproc.h"
  8.  
  9. VOIDED    LineDemo2D (HDC hdc)
  10. {
  11.     ViewerName (VL_CURRENT, "2D Lines");
  12.     PenColor (hdc, VL_RED);
  13.     MoveTo2D (hdc, 0, 0);
  14.     LineTo2D (hdc, 1, 1);
  15.     RLineTo2D (hdc, -2, 0);
  16.     RLineTo2D (hdc, 0, -2);
  17.     RLineTo2D (hdc, 2, 0);
  18.     RLineTo2D (hdc, 0, 2);
  19.     RMoveTo2D (hdc, 1, 1);
  20.     LineTo2D (hdc, -2, 2);
  21.     PenColor (hdc, VL_BLUE);
  22.     MoveTo2H (hdc, 1, 1, 0.5f);
  23.     LineTo2H (hdc, 0, 1, 0);
  24.     LineTo2H (hdc, 0, 0, 1);
  25.     MoveTo2H (hdc, -1, 1, 0.5f);
  26.     LineTo2H (hdc, -1, 0, 0);
  27.     LineTo2H (hdc, 0, 0, 1);
  28.     MoveTo2H (hdc, -1, -1, 0.5f);
  29.     LineTo2H (hdc, 0, -1, 0);
  30.     LineTo2H (hdc, 0, 0, 1);
  31.     MoveTo2H (hdc, 1, -1, 0.5f);
  32.     LineTo2H (hdc, 1, 0, 0);
  33.     LineTo2H (hdc, 0, 0, 1);
  34.     PenColor (hdc, VL_GREEN);
  35.     Line2D (hdc, -15, 5, 15, 5);
  36.     Line2D (hdc, -15, -5, 15, -5);
  37.     Line2D (hdc, -5, -15, -5, 15);
  38.     Line2D (hdc, 5, -15, 5, 15);
  39.     Line2D (hdc, -15, 0, 0, 15);
  40.     Line2D (hdc, 15, 0, 0, 15);
  41.     Line2D (hdc, 0, -15, 15, 0);
  42.     Line2D (hdc, 0, -15, -15, 0);
  43.     PenColor (hdc, VL_YELLOW);
  44.     Line2H (hdc, -5, 5, 0.75f, 5, 5, 0.75f);
  45.     Line2H (hdc, -5, -5, 0.75f, 5, -5, 0.75f);
  46.     Line2H (hdc, -5, -5, 0.75f, -5, 5, 0.75f);
  47.     Line2H (hdc, 5, -5, 0.75f, 5, 5, 0.75f);
  48.     PenColor (hdc, VL_BROWN);
  49.     RLine2D (hdc, 2, 3, -5, -5);
  50. }
  51.  
  52. VOIDED    PolylineDemo2D (HDC hdc)
  53. {
  54.     REAL    poly[] = {-1, -1, -1, 1, 1, 1, 1, -1};
  55.  
  56.     ViewerName (VL_CURRENT, "2D PolyLines");
  57.     PenColor (hdc, VL_RED);
  58.     Polyline2D (hdc, VL_2D, poly, 4);
  59.     PushTransformation2D (NULL);
  60.     TranslateTo2D (3, 3);
  61.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  62.     TranslateTo2D (10, 0);
  63.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  64.     TranslateTo2D (10, -6);
  65.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  66.     TranslateTo2D (-10, -6);
  67.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  68.     TranslateTo2D (-10, 6);
  69.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  70.     PopTransformation2D (NULL);
  71.     LineTo2D (hdc, 0, 0);
  72. }
  73.  
  74. VOIDED    PointerDemo2D (HDC hdc)
  75. {
  76.     REAL    x, y, a;
  77.     UINT    i;
  78.  
  79.     ViewerName (VL_CURRENT, "2D Pointers");
  80.     PenColor (hdc, VL_YELLOW);
  81.     for (i = 0, a = 0; i < 12; i++, a += 0.5f) {
  82.         x = (REAL) cos (a) * 9;
  83.         y = (REAL) sin (a) * 5;
  84.         Pointer2D (hdc, 0, 0, x, y, 1, 0.5f, VL_CLOSEDARROW);
  85.     }
  86. }
  87.  
  88. VOIDED    MarkDemo2D (HDC hdc)
  89. {
  90.     UINT    i, j;
  91.     REAL    x, y;
  92.  
  93.     ViewerName (VL_CURRENT, "2D Marks");
  94.     PenColor (hdc, VL_BLUE);
  95.     for (j = 0, y = -6; j < 7; j++, y += 2)
  96.         for (i = 0, x = -9; i < 10; i++, x += 2)
  97.             Mark2D (hdc, x, y, i+2, i+2, VL_CIRCLEMARK << j);
  98. }
  99.  
  100. VOIDED    LabelDemo2D (HDC hdc)
  101. {
  102.     ViewerName (VL_CURRENT, "2D Labels");
  103.     TextColor (hdc, VL_RED, VL_NONE);
  104.     PenColor (hdc, VL_GREEN);
  105.     SetTextAlign (hdc, TA_CENTER | TA_BASELINE);
  106.     Label2D (hdc, 0, 0, "Center & BaseLine");
  107.     Mark2D (hdc, 0, 0, 15, 5, VL_CROSSMARK);
  108.     SetTextAlign (hdc, TA_CENTER | TA_TOP);
  109.     Label2D (hdc, 0, 3, "Center & Top");
  110.     Mark2D (hdc, 0, 3, 15, 3, VL_CROSSMARK);
  111.     SetTextAlign (hdc, TA_CENTER | TA_BOTTOM);
  112.     Label2D (hdc, 0, -3, "Center & Bottom");
  113.     Mark2D (hdc, 0, -3, 15, 3, VL_CROSSMARK);
  114.  
  115.     SetTextAlign (hdc, TA_LEFT | TA_BASELINE);
  116.     Label2D (hdc, 3.5f, 0, "Left & BaseLine");
  117.     Mark2D (hdc, 3.5f, 0, 15, 5, VL_CROSSMARK);
  118.     SetTextAlign (hdc, TA_LEFT | TA_TOP);
  119.     Label2D (hdc, 3.5f, 3, "Left & Top");
  120.     Mark2D (hdc, 3.5f, 3, 15, 3, VL_CROSSMARK);
  121.     SetTextAlign (hdc, TA_LEFT | TA_BOTTOM);
  122.     Label2D (hdc, 3.5f, -3, "Left & Bottom");
  123.     Mark2D (hdc, 3.5f, -3, 15, 3, VL_CROSSMARK);
  124.  
  125.     SetTextAlign (hdc, TA_RIGHT | TA_BASELINE);
  126.     Label2D (hdc, -3.5f, 0, "Right & BaseLine");
  127.     Mark2D (hdc, -3.5f, 0, 15, 5, VL_CROSSMARK);
  128.     SetTextAlign (hdc, TA_RIGHT | TA_TOP);
  129.     Label2D (hdc, -3.5f, 3, "Right & Top");
  130.     Mark2D (hdc, -3.5f, 3, 15, 3, VL_CROSSMARK);
  131.     SetTextAlign (hdc, TA_RIGHT | TA_BOTTOM);
  132.     Label2D (hdc, -3.5f, -3, "Right & Bottom");
  133.     Mark2D (hdc, -3.5f, -3, 15, 3, VL_CROSSMARK);
  134. }
  135.  
  136. VOIDED    NetDemo2D (HDC hdc)
  137. {
  138.     REAL    net[140];
  139.     UINT    i, j, index = 0;
  140.     REAL    x, y;
  141.  
  142.     PenColor (hdc, VL_BLUE);
  143.     ;
  144.     for (i = 0, y = -6.5f; i < 7; i++, y += 2) {
  145.         for (j = 0, x = -9.5f; j < 10; j++, x += 2) {
  146.             net[index++] = x + ((REAL) rand () / RAND_MAX);
  147.             net[index++] = y + ((REAL) rand () / RAND_MAX);
  148.         }
  149.     }
  150.     Net2D (hdc, VL_2D, (VECTOR) net, 7, 10);
  151.     ViewerName (VL_CURRENT, "2D Net");
  152. }
  153.  
  154. VOIDED    Prime2D (HDC hdc, WORD func)
  155. {
  156.     switch (func) {
  157.         case IDM_2DPRIME_LINE:
  158.             LineDemo2D (hdc);
  159.             break;
  160.         case IDM_2DPRIME_POLYLINE:
  161.             PolylineDemo2D (hdc);
  162.             break;
  163.         case IDM_2DPRIME_POINTER:
  164.             PointerDemo2D (hdc);
  165.             break;
  166.         case IDM_2DPRIME_MARK:
  167.             MarkDemo2D (hdc);
  168.             break;
  169.         case IDM_2DPRIME_LABEL:
  170.             LabelDemo2D (hdc);
  171.             break;
  172.         case IDM_2DPRIME_NET:
  173.             NetDemo2D (hdc);
  174.             break;
  175.         case IDM_2DPRIME_SPIRAL:
  176.             PenColor (hdc, VL_YELLOW);
  177.             Spiral2D (hdc, 0, 0, 30, 5, 1, 1);
  178.             ViewerName (VL_CURRENT, "2D Spiral Curve");
  179.             break;
  180.     }
  181. }
  182.  
  183. VOIDED    LineDemo3D (HDC hdc)
  184. {
  185.     ViewerName (VL_CURRENT, "3D Lines");
  186.     PenColor (hdc, VL_RED);
  187.     MoveTo3D (hdc, 0, 0, 0);
  188.     LineTo3D (hdc, 10, 10, 0);
  189.     RLineTo3D (hdc, 0, -20, 0);
  190.     RLineTo3D (hdc, -20, 0, 0);
  191.     RLineTo3D (hdc, 0, 20, 0);
  192.     RLineTo3D (hdc, 20, 0, 0);
  193.     PenColor (hdc, VL_BLUE);
  194.     MoveTo3H (hdc, 1, 1, 0, 0.5f);
  195.     LineTo3H (hdc, 0, 1, 0, 0);
  196.     LineTo3H (hdc, 0, 0, 0, 1);
  197.     MoveTo3H (hdc, -1, 1, 0, 0.5f);
  198.     LineTo3H (hdc, -1, 0, 0, 0);
  199.     LineTo3H (hdc, 0, 0, 0, 1);
  200.     MoveTo3H (hdc, -1, -1, 0, 0.5f);
  201.     LineTo3H (hdc, 0, -1, 0, 0);
  202.     LineTo3H (hdc, 0, 0, 0, 1);
  203.     MoveTo3H (hdc, 1, -1, 0, 0.5f);
  204.     LineTo3H (hdc, 1, 0, 0, 0);
  205.     LineTo3H (hdc, 0, 0, 0, 1);
  206.     PenColor (hdc, VL_YELLOW);
  207.     MoveTo3D (hdc, 100, 100, 90);
  208.     LineTo3D (hdc, 10, 0, 0);
  209.     MoveTo3D (hdc, 100, 100, 90);
  210.     LineTo3D (hdc, 0, 10, 0);
  211.     MoveTo3D (hdc, 100, 100, 90);
  212.     LineTo3D (hdc, 0, 0, 10);
  213. }
  214.  
  215. VOIDED    PolylineDemo3D (HDC hdc)
  216. {
  217.     REAL    poly[] = {-1, -1, -1, 1, 1, 1, 1, -1};
  218.  
  219.     ViewerName (VL_CURRENT, "3D PolyLines");
  220.     PenColor (hdc, VL_RED);
  221.     Polyline3D (hdc, VL_2D, poly, 4);
  222.     PushTransformation3D (NULL);
  223.     Scale3D (5, 5, 5);
  224.     TranslateTo3D (3, 3, 0);
  225.     PenColor (hdc, VL_GREEN);
  226.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  227.     TranslateTo3D (10, 0, 0);
  228.     PenColor (hdc, VL_BLUE);
  229.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  230.     TranslateTo3D (10, -6, 0);
  231.     PenColor (hdc, VL_YELLOW);
  232.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  233.     TranslateTo3D (-10, -6, 0);
  234.     PenColor (hdc, VL_BROWN);
  235.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  236.     TranslateTo3D (-10, 6, 0);
  237.     PenColor (hdc, VL_WHITE);
  238.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  239.     PopTransformation3D (NULL);
  240.     LineTo3D (hdc, 0, 0, 0);
  241. }
  242.  
  243. VOIDED    PointerDemo3D (HDC hdc)
  244. {
  245.     ViewerName (VL_CURRENT, "3D Pointers");
  246.     PenColor (hdc, VL_RED);
  247.     Pointer3D (hdc, 0, 0, 0, 20, 0, 0, 5, 3, VL_OPENARROW);
  248.     PenColor (hdc, VL_GREEN);
  249.     Pointer3D (hdc, 0, 0, 0, 0, 20, 0, 5, 3, VL_CLOSEDARROW);
  250.     PenColor (hdc, VL_BLUE);
  251.     Pointer3D (hdc, 0, 0, 0, 0, 0, 20, 5, 3, VL_CROSSMARK);
  252.     PenColor (hdc, VL_YELLOW);
  253.     Pointer3D (hdc, 0, 0, 0, -20, 0, 0, 5, 3, VL_HEXAGONMARK);
  254.     PenColor (hdc, VL_BROWN);
  255.     Pointer3D (hdc, 0, 0, 0, 0, -20, 0, 5, 3, VL_TRIANGLEMARK);
  256.     PenColor (hdc, VL_WHITE);
  257.     Pointer3D (hdc, 0, 0, 0, 0, 0, -20, 5, 3, VL_BOXMARK);
  258. }
  259.  
  260. VOIDED    MarkDemo3D (HDC hdc)
  261. {
  262.     ViewerName (VL_CURRENT, "3D Marks");
  263.     PenColor (hdc, VL_RED);
  264.     Mark3D (hdc, 0, 0, 0, 5, 5, VL_CROSSMARK);
  265.     PenColor (hdc, VL_GREEN);
  266.     Mark3D (hdc, 20, 0, 0, 5, 5, VL_HEXAGONMARK);
  267.     PenColor (hdc, VL_BLUE);
  268.     Mark3D (hdc, 0, 20, 0, 5, 5, VL_DIAMONDMARK);
  269.     PenColor (hdc, VL_WHITE);
  270.     Mark3D (hdc, 0, 0, 20, 5, 5, VL_TRIANGLEMARK);
  271. }
  272.  
  273. VOIDED    LabelDemo3D (HDC hdc)
  274. {
  275.     int    method;
  276.  
  277.     ViewerName (VL_CURRENT, "3D Labels");
  278.     Scale3D (2, 2, 2);
  279.     method = ShadingMethod (VL_WIREFRAME);
  280.     PenColor (hdc, VL_GREEN);
  281.     Cube (hdc, 20, 20, 20);
  282.     ShadingMethod (method);
  283.     TextColor (hdc, VL_RED, VL_NONE);
  284.     SetTextAlign (hdc, TA_BOTTOM | TA_CENTER);
  285.     Label3D (hdc, -10, -10, 10, "Back Top");
  286.     SetTextAlign (hdc, TA_BASELINE | TA_CENTER);
  287.     Label3D (hdc, 10, 10, 10, "Front Top");
  288.     SetTextAlign (hdc, TA_TOP | TA_CENTER);
  289.     Label3D (hdc, 10, 10, -10, "Front Bottom");
  290.     SetTextAlign (hdc, TA_BASELINE | TA_RIGHT);
  291.     Label3D (hdc, 10, -10, 10, "Left Top");
  292.     Label3D (hdc, 10, -10, -10, "Left Bottom");
  293.     SetTextAlign (hdc, TA_BASELINE | TA_LEFT);
  294.     Label3D (hdc, -10, 10, 10, "Right Top");
  295.     Label3D (hdc, -10, 10, -10, "Right Bottom");
  296. }
  297.  
  298. VOIDED    NetDemo3D (HDC hdc)
  299. {
  300.     REAL    x, y, net[210];
  301.     UINT    i, j, index = 0;
  302.  
  303.     PushTransformation3D (NULL);
  304.     Scale3D (5, 5, 5);
  305.     PenColor (hdc, VL_BLUE);
  306.     for (i = 0, y = -6.5f; i < 7; i++, y += 2) {
  307.         for (j = 0, x = -9.5f; j < 10; j++, x += 2) {
  308.             net[index++] = x + ((REAL) rand () / RAND_MAX);
  309.             net[index++] = y + ((REAL) rand () / RAND_MAX);
  310.             net[index++] = (REAL) rand () / RAND_MAX;
  311.         }
  312.     }
  313.     Net3D (hdc, VL_3D, (VECTOR) net, 7, 10);
  314.     PopTransformation3D (NULL);
  315.     ViewerName (VL_CURRENT, "3D Net");
  316. }
  317.  
  318. VOIDED    Prime3D (HDC hdc, WORD func)
  319. {
  320.     MarkPosition3D (hdc, 0, 0, 0, 10, VL_ORIGIN);
  321.     switch (func) {
  322.         case IDM_3DPRIME_LINE:
  323.             LineDemo3D (hdc);
  324.             break;
  325.         case IDM_3DPRIME_POLYLINE:
  326.             PolylineDemo3D (hdc);
  327.             break;
  328.         case IDM_3DPRIME_POINTER:
  329.             PointerDemo3D (hdc);
  330.             break;
  331.         case IDM_3DPRIME_MARK:
  332.             MarkDemo3D (hdc);
  333.             break;
  334.         case IDM_3DPRIME_LABEL:
  335.             LabelDemo3D (hdc);
  336.             break;
  337.         case IDM_3DPRIME_NET:
  338.             NetDemo3D (hdc);
  339.             break;
  340.         case IDM_3DPRIME_SPIRAL:
  341.             MarkPosition3D (hdc, 0, 0, 0, 20, VL_ORIGIN);
  342.             PenColor (hdc, VL_GREEN);
  343.             Spiral3D (hdc, 0, 10, 0, 0.5f, 40);
  344.             PenColor (hdc, VL_YELLOW);
  345.             Rotate3D (90, 'y');
  346.             Spiral3D (hdc, 0, 10, 0, 0.5f, 40);
  347.             PenColor (hdc, VL_RED);
  348.             Rotate3D (-90, 'x');
  349.             Spiral3D (hdc, 0, 10, 0, 0.5f, 40);
  350.             ViewerName (VL_CURRENT, "3D Spiral");
  351.             break;
  352.         case IDM_3DPRIME_SPRING:
  353.             MarkPosition3D (hdc, 0, 0, 0, 20, VL_ORIGIN);
  354.             PenColor (hdc, VL_BLUE);
  355.             Spring3D (hdc, 30, 10, 10, 40);
  356.             PenColor (hdc, VL_YELLOW);
  357.             Rotate3D (90, 'y');
  358.             Spring3D (hdc, 30, 10, 10, 40);
  359.             PenColor (hdc, VL_GREEN);
  360.             Rotate3D (-90, 'x');
  361.             Spring3D (hdc, 30, 10, 10, 40);
  362.             ViewerName (VL_CURRENT, "3D Springs");
  363.             break;
  364.     }
  365. }
  366.  
  367. VOIDED    DrawNgon (HDC hdc, WORD type)
  368. {
  369.     REAL    x, y, t, w, h;
  370.     WORD    i, j, n;
  371.  
  372.     t = 0;
  373.     w = h = 1.75f;
  374.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  375.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  376.             n = i * 4 + j;
  377.             PenColor (hdc, (WORD)(VL_RED + n));
  378.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  379.             n += 3;
  380.             if (type == VL_THREED)
  381.                 Ngon3D (hdc, x, y, t, w, h, n);
  382.             else
  383.                 Ngon2D (hdc, x, y, t, w, h, n);
  384.         }
  385.     }
  386. }
  387.  
  388. VOIDED    DrawStar (HDC hdc, WORD type)
  389. {
  390.     REAL    x, y, t, w, h;
  391.     UINT    i, j, n;
  392.  
  393.     t = 0; w = h = 1.75f;
  394.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  395.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  396.             n = i * 4 + j;
  397.             PenColor (hdc, (WORD)(VL_RED + n));
  398.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  399.             n += 3;
  400.             if (type == VL_THREED)
  401.                 Star3D (hdc, x, y, t, w, h, n);
  402.             else
  403.                 Star2D (hdc, x, y, t, w, h, n);
  404.         }
  405.     }
  406. }
  407.  
  408. VOIDED    DrawFlower (HDC hdc, WORD type)
  409. {
  410.     REAL    x, y, t, w, h, r;
  411.     UINT    i, j, n;
  412.  
  413.     t = 0; w = h = 1.75f; r = 0.75f;
  414.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  415.         ;
  416.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  417.             n = i * 4 + j;
  418.             PenColor (hdc, (WORD)(VL_RED + n));
  419.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  420.             n += 3;
  421.             if (type == VL_THREED)
  422.                 Flower3D (hdc, x, y, t, w, h, n, r);
  423.             else
  424.                 Flower2D (hdc, x, y, t, w, h, n, r);
  425.         }
  426.     }
  427. }
  428.  
  429. VOIDED    DrawPie (HDC hdc, WORD type)
  430. {
  431.     REAL    x, y, t, w, h, a, b;
  432.     UINT    i, j, n;
  433.  
  434.     t = 0;
  435.     a = 0; w = h = 1.75f;
  436.     for (i = 0, y = -6; i < 4; i++, y += 4) {
  437.         for (j = 0, x = -7.5f, b = 30; j < 4; j++, x += 5, b += 30) {
  438.             n = i * 4 + j;
  439.             PenColor (hdc, (WORD)(VL_RED + n));
  440.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  441.             if (type == VL_THREED)
  442.                 Pie3D (hdc, x, y, t, w, h, a, b);
  443.             else
  444.                 Pie2D (hdc, x, y, t, w, h, a, b);
  445.         }
  446.         t += 90;
  447.     }
  448. }
  449.  
  450. VOIDED    DrawDisk (HDC hdc, WORD type)
  451. {
  452.     REAL    x, y, t, w, h;
  453.     UINT    i, j, n;
  454.  
  455.     t = 0;
  456.     w = 2; h = 0.2f;
  457.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  458.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  459.             n = i * 4 + j;
  460.             PenColor (hdc, (WORD)(VL_RED + n));
  461.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  462.             if (type == VL_THREED)
  463.                 Disk3D (hdc, x, y, t, w, h);
  464.             else
  465.                 Disk2D (hdc, x, y, t, w, h);
  466.             t += 15;
  467.             w -= 0.15f;
  468.             h += 0.15f;
  469.         }
  470.     }
  471. }
  472.  
  473. VOIDED    DrawRose (HDC hdc, WORD type)
  474. {
  475.     REAL    x, y, t, r;
  476.     UINT    i, j, m, n;
  477.  
  478.     t = 0;
  479.     r = 2;
  480.     for (i = 0, y = -4; i < 3; i++, y += 4) {
  481.         n = i + 1;
  482.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  483.             switch (n) {
  484.                 case 1:
  485.                     m = j + 2;
  486.                     break;
  487.                 case 2:
  488.                     m = j * 2 + 1;
  489.                     break;
  490.                 case 3:
  491.                     m = j + 1 + j / 2;
  492.                     break;
  493.             }
  494.             PenColor (hdc, (WORD)(VL_RED + i * 4 + j));
  495.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  496.             if (type == VL_THREED)
  497.                 Rose3D (hdc, x, y, t, r, m, n);
  498.             else
  499.                 Rose2D (hdc, x, y, t, r, m, n);
  500.             t += 15;
  501.         }
  502.     }
  503. }
  504.  
  505. VOIDED    DrawBox (HDC hdc, WORD type)
  506. {
  507.     REAL    x, y, t, w, h;
  508.     UINT    i, j, n;
  509.  
  510.     t = 0;
  511.     w = 3; h = 0.6f;
  512.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  513.         for (j = 0, x = -7.5f; j < 4; j++, x += 5, w -= 0.2f, h += 0.2f) {
  514.             n = i * 4 + j;
  515.             PenColor (hdc, (WORD)(VL_RED + n));
  516.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  517.             if (type == VL_THREED)
  518.                 Box3D (hdc, x, y, t, w, h);
  519.             else
  520.                 Box2D (hdc, x, y, t, w, h);
  521.             t += 15;
  522.         }
  523.     }
  524. }
  525.  
  526. VOIDED    DrawChord (HDC hdc, WORD type)
  527. {
  528.     REAL    x, y, t, w, h, a, b;
  529.     UINT    i, j, n;
  530.  
  531.     t = 0;
  532.     a = 0; b = 30; w = h = 1.75f;
  533.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  534.         for (j = 0, x = -7.5f; j < 4; j++, x += 5, b += 30, t += 15) {
  535.             n = i * 4 + j;
  536.             PenColor (hdc, (WORD)(VL_RED + n));
  537.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  538.             if (type == VL_THREED)
  539.                 Chord3D (hdc, x, y, a, w, h, a, b);
  540.             else
  541.                 Chord2D (hdc, x, y, a, w, h, a, b);
  542.         }
  543.     }
  544. }
  545.  
  546. VOIDED    DrawRing (HDC hdc, WORD type)
  547. {
  548.     REAL    x, y, t, w, h, a, b;
  549.     UINT    i, j, n;
  550.  
  551.     ; t = 0;
  552.     a = 0; b = 30; w = h = 1;
  553.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  554.         for (j = 0, x = -7.5f; j < 4; j++, x += 5, b += 30, t += 15) {
  555.             n = i * 4 + j;
  556.             PenColor (hdc, (WORD)(VL_RED + n));
  557.             BrushColor (hdc, (WORD)(VL_RED + j * 3 + i));
  558.             if (type == VL_THREED)
  559.                 Ring3D (hdc, x, y, a, w, h, a, b, 0.5f);
  560.             else
  561.                 Ring2D (hdc, x, y, a, w, h, a, b, 0.5f);
  562.         }
  563.     }
  564. }
  565.  
  566. VOIDED    DrawBezierCurve (HDC hdc, WORD type)
  567. {
  568.     REAL    point[40];
  569.  
  570.     point[0] = -8; point[1] = 3.5f;
  571.     point[2] = -5; point[3] = 6;
  572.     point[4] = -5; point[5] = 1;
  573.     point[6] = -2; point[7] = 3.5f;
  574.     PenColor (hdc, VL_WHITE);
  575.     if (type == VL_TWOD)
  576.         BezierCurve2D (hdc, VL_2D, point);
  577.     else
  578.         BezierCurve3D (hdc, VL_2D, point);
  579.     PenColor (hdc, VL_GREEN);
  580.     if (type == VL_TWOD)
  581.         Polyline2D (hdc, VL_2D, point, 4);
  582.     else
  583.         Polyline3D (hdc, VL_2D, point, 4);
  584.     PenColor (hdc, VL_WHITE);
  585.     if (type == VL_TWOD)
  586.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_HEXAGONMARK);
  587.     else
  588.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_HEXAGONMARK);
  589.  
  590.     point[0] = 2; point[1] = 3.5f;
  591.     point[2] = 5; point[3] = 6;
  592.     point[4] = 8; point[5] = 3.5f;
  593.     point[6] = 5; point[7] = 1;
  594.     PenColor (hdc, VL_WHITE);
  595.     if (type == VL_TWOD)
  596.         BezierCurve2D (hdc, VL_2D, point);
  597.     else
  598.         BezierCurve3D (hdc, VL_2D, point);
  599.     PenColor (hdc, VL_GREEN);
  600.     if (type == VL_TWOD)
  601.         Polyline2D (hdc, VL_2D, point, 4);
  602.     else
  603.         Polyline3D (hdc, VL_2D, point, 4);
  604.     PenColor (hdc, VL_WHITE);
  605.     if (type == VL_TWOD)
  606.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_CROSSMARK);
  607.     else
  608.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_CROSSMARK);
  609.  
  610.     point[0] = -8; point[1] = -3;
  611.     point[2] = -2; point[3] = -6;
  612.     point[4] = -2; point[5] = -1;
  613.     point[6] = -8; point[7] = -5;
  614.     PenColor (hdc, VL_WHITE);
  615.     if (type == VL_TWOD)
  616.         BezierCurve2D (hdc, VL_2D, point);
  617.     else
  618.         BezierCurve3D (hdc, VL_2D, point);
  619.     PenColor (hdc, VL_GREEN);
  620.     if (type == VL_TWOD)
  621.         Polyline2D (hdc, VL_2D, point, 4);
  622.     else
  623.         Polyline3D (hdc, VL_2D, point, 4);
  624.     PenColor (hdc, VL_WHITE);
  625.     if (type == VL_TWOD)
  626.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_XMARK);
  627.     else
  628.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_XMARK);
  629.  
  630.     point[0] = 2; point[1] = -6;
  631.     point[2] = 5; point[3] = -1;
  632.     point[4] = 8; point[5] = -6;
  633.     point[6] = 2; point[7] = -6;
  634.     PenColor (hdc, VL_WHITE);
  635.     if (type == VL_TWOD)
  636.         BezierCurve2D (hdc, VL_2D, point);
  637.     else
  638.         BezierCurve3D (hdc, VL_2D, point);
  639.     PenColor (hdc, VL_GREEN);
  640.     if (type == VL_TWOD)
  641.         Polyline2D (hdc, VL_2D, point, 4);
  642.     else
  643.         Polyline3D (hdc, VL_2D, point, 4);
  644.     PenColor (hdc, VL_WHITE);
  645.     if (type == VL_TWOD)
  646.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_DIAMONDMARK);
  647.     else
  648.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_DIAMONDMARK);
  649. }
  650.  
  651. VOIDED    DrawBSplineCurve (HDC hdc, WORD type)
  652. {
  653.     REAL    point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0};
  654.     REAL    knot[20] = {0, 0, 0, 1, 2, 3, 3, 3, 4, 5, 6, 6, 6};
  655.  
  656.     PenColor (hdc, VL_RED);
  657.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 8);
  658.     if (type == VL_TWOD)
  659.         Polyline2D (hdc, VL_2D, point, 8);
  660.     else
  661.         Polyline3D (hdc, VL_2D, point, 8);
  662.     PenColor (hdc, VL_BLUE);
  663.     if (type == VL_TWOD)
  664.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  665.     else
  666.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  667.     
  668.     PenColor (hdc, VL_GREEN);
  669.     if (type == VL_TWOD)
  670.         BSplineCurve2D (hdc, VL_2D, point, 8);
  671.     else
  672.         BSplineCurve3D (hdc, VL_2D, point, 8);
  673.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  674.     PenColor (hdc, VL_RED);
  675.     if (type == VL_TWOD)
  676.         Polyline2D (hdc, VL_2D, point, 8);
  677.     else
  678.         Polyline3D (hdc, VL_2D, point, 8);
  679.     PenColor (hdc, VL_BLUE);
  680.     if (type == VL_TWOD)
  681.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  682.     else
  683.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  684.     PenColor (hdc, VL_GREEN);
  685.     if (type == VL_TWOD)
  686.         SplineInterp2D (hdc, VL_2D, point, 8);
  687.     else
  688.         SplineInterp3D (hdc, VL_2D, point, 8);
  689.     TransfVertex (VL_2D, -10, -6, 0, 1, 1, point, 8);
  690.     PenColor (hdc, VL_RED);
  691.     if (type == VL_TWOD)
  692.         Polyline2D (hdc, VL_2D, point, 8);
  693.     else
  694.         Polyline3D (hdc, VL_2D, point, 8);
  695.  
  696.     PenColor (hdc, VL_BLUE);
  697.     if (type == VL_TWOD)
  698.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  699.     else
  700.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  701.     PenColor (hdc, VL_GREEN);
  702.     if (type == VL_TWOD)
  703.         BSplineCurveClosed2D (hdc, VL_2D, point, 8);
  704.     else
  705.         BSplineCurveClosed3D (hdc, VL_2D, point, 8);
  706.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  707.     PenColor (hdc, VL_RED);
  708.     if (type == VL_TWOD)
  709.         Polyline2D (hdc, VL_2D, point, 8);
  710.     else
  711.         Polyline3D (hdc, VL_2D, point, 8);
  712.     PenColor (hdc, VL_BLUE);
  713.     if (type == VL_TWOD)
  714.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  715.     else
  716.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  717.     PenColor (hdc, VL_GREEN);
  718.     if (type == VL_TWOD)
  719.         NURBSCurveClosed2D (hdc, VL_2D, point, 8, knot);
  720.     else
  721.         NURBSCurveClosed3D (hdc, VL_2D, point, 8, knot);
  722. }
  723.  
  724. VOIDED    DrawCatmullRomCurve (HDC hdc, WORD type)
  725. {
  726.     REAL    point[] = {0, 0, 0, 1, 1, 1, 1, 0, 2, 0, 3, 1, 4, 1, 4, 0};
  727.  
  728.     TransfVertex (VL_2D, -8, -4, 0, 4, 8, point, 8);
  729.     PenColor (hdc, VL_RED);
  730.     if (type == VL_TWOD)
  731.         Polyline2D (hdc, VL_2D, point, 8);
  732.     else
  733.         Polyline3D (hdc, VL_2D, point, 8);
  734.     PenColor (hdc, VL_BLUE);
  735.     if (type == VL_TWOD)
  736.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  737.     else
  738.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  739.     PenColor (hdc, VL_GREEN);
  740.     if (type == VL_TWOD)
  741.         CatmullRomSpline2D (hdc, VL_2D, point, 8);
  742.     else
  743.         CatmullRomSpline3D (hdc, VL_2D, point, 8);
  744. }
  745.  
  746. void    heart (HDC hdc, WORD type, BOOL showpnt)
  747. {
  748.     REAL point[] = {0, 0, 0.4f, 0.8f, 2, 1.4f, 2.5f, -1, 1, -2, 0, -3,
  749.                     -1, -2, -2.5f, -1, -2, 1.4f,
  750.                     -0.4f, 0.8f, 0, 0};
  751.     REAL    knot[20] = {0, 0, 0, 1, 2, 3, 3, 3, 4, 5, 6, 6, 6};
  752.  
  753.     if (type == VL_TWOD) {
  754.         PenColor (hdc, VL_RED);
  755.         PushTransformation2D (NULL);
  756.         Scale2D (2, 2);
  757.         NURBSCurve2D (hdc, VL_2D, point, 11, knot);
  758.     }
  759.     else {
  760.         PenColor (hdc, VL_WHITE);
  761.         PushTransformation3D (NULL);
  762.         Scale3D (3, 3, 3);
  763.         NURBSCurve3D (hdc, VL_2D, point, 11, knot);
  764.     }
  765.     if (showpnt) {
  766.         if (type == VL_TWOD) {
  767.             PenColor (hdc, VL_GREEN);
  768.             ClosedPolyline2D (hdc, VL_2D, point, 10); 
  769.             PolyMark2D (hdc, VL_2D, point, 10, 4, 4, VL_BOXMARK);
  770.         }
  771.         else {
  772.             PenColor (hdc, VL_BLUE);
  773.             ClosedPolyline3D (hdc, VL_2D, point, 10); 
  774.             PolyMark3D (hdc, VL_2D, point, 10, 4, 4, VL_BOXMARK);
  775.         }
  776.     }
  777.     if (type == VL_TWOD)
  778.         PopTransformation2D (NULL);
  779.     else
  780.         PopTransformation3D (NULL);
  781. }
  782.  
  783. void    circle (HDC hdc, WORD type, BOOL showpnt)
  784. {
  785.     POINT2H p[20] = {
  786.         {0, 1, 1}, {0.707f, 0.707f, 0.707f}, {1, 0, 1},
  787.         {0.707f, -0.707f, 0.707f}, {0, -1, 1}, {-0.707f, -0.707f, 0.707f},
  788.         {-1, 0, 1}, {-0.707f, 0.707f, 0.707f}, {0, 1, 1}};
  789.     REAL    knot[20] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
  790.  
  791.     if (type == VL_TWOD) {
  792.         PenColor (hdc, VL_RED);
  793.         PushTransformation2D (NULL);
  794.         Scale2D (3, 3);
  795.         QNURBSCurve2D (hdc, VL_2H, (VECTOR) p, 9, knot);
  796.     }
  797.     else {
  798.         PenColor (hdc, VL_WHITE);
  799.         PushTransformation3D (NULL);
  800.         Scale3D (3, 3, 3);
  801.         QNURBSCurve3D (hdc, VL_2H, (VECTOR) p, 9, knot);
  802.     }
  803.     if (showpnt) {
  804.         if (type == VL_TWOD) {
  805.             PenColor (hdc, VL_GREEN);
  806.             ClosedPolyline2D (hdc, VL_2H, (VECTOR) p, 8);
  807.             PolyMark2D (hdc, VL_2H, (VECTOR) p, 8, 4, 4, VL_BOXMARK);
  808.         }
  809.         else {
  810.             PenColor (hdc, VL_BLUE);
  811.             ClosedPolyline3D (hdc, VL_2H, (VECTOR) p, 8);
  812.             PolyMark3D (hdc, VL_2H, (VECTOR) p, 8, 4, 4, VL_BOXMARK);
  813.         }
  814.     }
  815.     if (type == VL_TWOD)
  816.         PopTransformation2D (NULL);
  817.     else
  818.         PopTransformation3D (NULL);
  819. }
  820.  
  821. VOIDED    DrawNURBSCurve (HDC hdc, WORD type)
  822. {
  823.     circle (hdc, type, TRUE);
  824.     heart (hdc, type, TRUE);
  825. }
  826.  
  827. VOIDED    DrawHermitCurve (HDC hdc, WORD type)
  828. {
  829.     REAL    point[20];
  830.  
  831.     point[0] = -6; point[1] = -1; point[2] = 6; point[3] = -1;
  832.     point[4] = -10; point[5] = 0; point[6] = 0; point[7] = -40;
  833.     PenColor (hdc, VL_WHITE);
  834.     if (type == VL_TWOD)
  835.         HermitCurve2D (hdc, VL_2D, point);
  836.     else
  837.         HermitCurve3D (hdc, VL_2D, point);
  838.     PenColor (hdc, VL_GREEN);    
  839.     if (type == VL_TWOD) {
  840.         Arrow2D (hdc, point[0], point[1], point[4], point[5],
  841.             4, 1, 0.5f, VL_OPENARROW);
  842.         Arrow2D (hdc, point[2], point[3], point[6], point[7],
  843.             4, 1, 0.5f, VL_OPENARROW);
  844.     }
  845.     else {
  846.         Arrow3D (hdc, point[0], point[1], 0, point[4], point[5], 0,
  847.             4, 1, 0.5f, VL_OPENARROW);
  848.         Arrow3D (hdc, point[2], point[3], 0, point[6], point[7], 0,
  849.             4, 1, 0.5f, VL_OPENARROW);
  850.     }
  851.     PenColor (hdc, VL_WHITE);
  852.     if (type == VL_TWOD) {
  853.         Mark2D (hdc, point[0], point[1], 4, 4, VL_DIAMONDMARK);
  854.         Mark2D (hdc, point[2], point[3], 4, 4, VL_DIAMONDMARK);
  855.     }
  856.     else {
  857.         Mark3D (hdc, point[0], point[1], 0, 4, 4, VL_DIAMONDMARK);
  858.         Mark3D (hdc, point[2], point[3], 0, 4, 4, VL_DIAMONDMARK);
  859.     }
  860. }
  861.  
  862. VOIDED    DrawNURBSCurveKnot (HDC hdc, WORD type)
  863. {
  864.     REAL point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0};
  865.     REAL Knot1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  866.     REAL Knot2[] = {0, 0, 0, 1, 1, 1, 4, 5, 5, 5};
  867.     REAL Knot3[] = {0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 6};
  868.     REAL Knot4[] = {0, 0, 0, 1, 3, 5, 7, 9, 10, 15};
  869.  
  870.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 8);
  871.     PenColor (hdc, VL_RED);
  872.     if (type == VL_TWOD)
  873.         Polyline2D (hdc, VL_2D, point, 8);
  874.     else
  875.         Polyline3D (hdc, VL_2D, point, 8);
  876.         
  877.     PenColor (hdc, VL_BLUE);
  878.     if (type == VL_TWOD)
  879.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  880.     else
  881.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  882.     PenColor (hdc, VL_GREEN);
  883.     if (type == VL_TWOD)
  884.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot1);
  885.     else
  886.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot1);
  887.  
  888.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  889.     PenColor (hdc, VL_RED);
  890.     if (type == VL_TWOD)
  891.         Polyline2D (hdc, VL_2D, point, 8);
  892.     else
  893.         Polyline3D (hdc, VL_2D, point, 8);
  894.     PenColor (hdc, VL_BLUE);
  895.     if (type == VL_TWOD)
  896.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  897.     else
  898.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  899.     PenColor (hdc, VL_GREEN);
  900.     if (type == VL_TWOD)
  901.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot2);
  902.     else
  903.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot2);
  904.  
  905.     TransfVertex (VL_2D, -10, -6, 0, 1, 1, point, 8);
  906.     PenColor (hdc, VL_RED);
  907.     if (type == VL_TWOD)
  908.         Polyline2D (hdc, VL_2D, point, 8);
  909.     else
  910.         Polyline3D (hdc, VL_2D, point, 8);
  911.     PenColor (hdc, VL_BLUE);
  912.     if (type == VL_TWOD)
  913.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  914.     else
  915.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  916.     PenColor (hdc, VL_GREEN);
  917.     if (type == VL_TWOD)
  918.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot3);
  919.     else
  920.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot3);
  921.  
  922.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  923.     PenColor (hdc, VL_RED);
  924.     if (type == VL_TWOD)
  925.         Polyline2D (hdc, VL_2D, point, 8);
  926.     else
  927.         Polyline3D (hdc, VL_2D, point, 8);
  928.     PenColor (hdc, VL_BLUE);
  929.     if (type == VL_TWOD)
  930.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  931.     else
  932.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  933.     PenColor (hdc, VL_GREEN);
  934.     if (type == VL_TWOD)
  935.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot4);
  936.     else
  937.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot4);
  938. }
  939.  
  940. VOIDED    DrawQNURBSCurve (HDC hdc, WORD type)
  941. {
  942.     REAL    point[] = {0, 1, 1, 0.707f, 0.707f, 0.707f, 1, 0, 1,
  943.         0.707f, -0.707f, 0.707f, 0, -1, 1, -0.707f, -0.707f, 0.707f,
  944.         -1, 0, 1, -0.707f, 0.707f, 0.707f, 0, 1, 1};
  945.     REAL knot[] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
  946.  
  947.     PenColor (hdc, VL_RED);
  948.     if (type == VL_TWOD) {
  949.         PushTransformation2D (NULL);
  950.         Translate2D (-5, -3);
  951.         Scale2D (3, 3);
  952.         ClosedPolyline2D (hdc, VL_2H, point, 8);
  953.     }
  954.     else {
  955.         PushTransformation3D (NULL);
  956.         Translate3D (-5, -3, 0);
  957.         Scale3D (3, 3, 3);
  958.         ClosedPolyline3D (hdc, VL_2H, point, 8);
  959.     }
  960.     PenColor (hdc, VL_BLUE);
  961.     if (type == VL_TWOD)
  962.         PolyMark2D (hdc, VL_2H, point, 8, 3, 3, VL_DIAMONDMARK);
  963.     else
  964.         PolyMark3D (hdc, VL_2H, point, 8, 3, 3, VL_DIAMONDMARK);
  965.     PenColor (hdc, VL_GREEN);
  966.     if (type == VL_TWOD) {
  967.         QNURBSCurve2D (hdc, VL_2H, point, 9, knot);
  968.         PopTransformation2D (NULL);
  969.     }
  970.     else {
  971.         QNURBSCurve3D (hdc, VL_2H, point, 9, knot);
  972.         PopTransformation3D (NULL);
  973.     }
  974. }
  975.  
  976. VOIDED    DrawQuadraticCurve (HDC hdc, WORD type)
  977. {
  978.     REAL    point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0, 0, 0};
  979.     REAL    knot[20] = {0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7};
  980.     UINT    i;
  981.  
  982.     PenColor (hdc, VL_RED);
  983.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 9);
  984.     if (type == VL_TWOD)
  985.         ClosedPolyline2D (hdc, VL_2D, point, 8);
  986.     else
  987.         ClosedPolyline3D (hdc, VL_2D, point, 8);
  988.     PenColor (hdc, VL_BLUE);
  989.     if (type == VL_TWOD)
  990.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  991.     else
  992.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  993.     PenColor (hdc, VL_GREEN);
  994.     if (type == VL_TWOD) {
  995.         for (i = 0; i < 7; i += 2)
  996.             QBezierCurve2D (hdc, VL_2D, &point[i*2]);
  997.     }
  998.     else {
  999.         for (i = 0; i < 7; i += 2)
  1000.             QBezierCurve3D (hdc, VL_2D, &point[i*2]);
  1001.     }
  1002.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 9);
  1003.     PenColor (hdc, VL_RED);
  1004.     if (type == VL_TWOD)
  1005.         ClosedPolyline2D (hdc, VL_2D, point, 8);
  1006.     else
  1007.         ClosedPolyline3D (hdc, VL_2D, point, 8);
  1008.     PenColor (hdc, VL_BLUE);
  1009.     if (type == VL_TWOD)
  1010.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1011.     else
  1012.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1013.     PenColor (hdc, VL_GREEN);
  1014.     if (type == VL_TWOD)
  1015.         QBSplineCurve2D (hdc, VL_2D, point, 9);
  1016.     else
  1017.         QBSplineCurve3D (hdc, VL_2D, point, 9);
  1018.  
  1019.     TransfVertex (VL_2D, 0, -6, 0, 1, 1, point, 9);
  1020.     PenColor (hdc, VL_RED);
  1021.     if (type == VL_TWOD)
  1022.         Polyline2D (hdc, VL_2D, point, 8);
  1023.     else
  1024.         Polyline3D (hdc, VL_2D, point, 8);
  1025.     PenColor (hdc, VL_BLUE);
  1026.     if (type == VL_TWOD)
  1027.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1028.     else
  1029.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1030.     PenColor (hdc, VL_GREEN);
  1031.     if (type == VL_TWOD)
  1032.         QNURBSCurve2D (hdc, VL_2D, point, 8, knot);
  1033.     else
  1034.         QNURBSCurve3D (hdc, VL_2D, point, 8, knot);
  1035.     DrawQNURBSCurve (hdc, type);
  1036. }
  1037.  
  1038. VOIDED    SelectPrimitives (HDC hdc, WORD cmd)
  1039. {
  1040.     switch (cmd) {
  1041.         case IDM_2DCURVE_BEZIER:
  1042.             ViewerName (VL_CURRENT, "Bezier Curves in 2D");
  1043.             DrawBezierCurve (hdc, VL_TWOD);
  1044.             break;
  1045.         case IDM_3DCURVE_BEZIER:
  1046.             ViewerName (VL_CURRENT, "Bezier Curves in 3D");
  1047.             DrawBezierCurve (hdc, VL_THREED);
  1048.             break;
  1049.         case IDM_2DCURVE_BSPLINE:
  1050.             ViewerName (VL_CURRENT, "B-Spline Curves in 2D");
  1051.             DrawBSplineCurve (hdc, VL_TWOD);
  1052.             break;
  1053.         case IDM_3DCURVE_BSPLINE:
  1054.             ViewerName (VL_CURRENT, "B-Spline Curves in 3D");
  1055.             DrawBSplineCurve (hdc, VL_THREED);
  1056.             break;
  1057.         case IDM_2DCURVE_HERMIT:
  1058.             ViewerName (VL_CURRENT, "2D Hermit Curves");
  1059.             DrawHermitCurve (hdc, VL_TWOD);
  1060.             break;
  1061.         case IDM_3DCURVE_HERMIT:
  1062.             ViewerName (VL_CURRENT, "3D Hermit Curves");
  1063.             DrawHermitCurve (hdc, VL_THREED);
  1064.             break;
  1065.         case IDM_2DCURVE_NURBSKNOTS:
  1066.             ViewerName (VL_CURRENT, "2D NUBRS Curves w/ Different Knots");
  1067.             DrawNURBSCurveKnot (hdc, VL_TWOD);
  1068.             break;
  1069.         case IDM_3DCURVE_NURBSKNOTS:
  1070.             ViewerName (VL_CURRENT, "3D NUBRS Curves w/ Different Knots");
  1071.             DrawNURBSCurveKnot (hdc, VL_THREED);
  1072.             break;
  1073.         case IDM_2DCURVE_CATMULLROM:
  1074.             ViewerName (VL_CURRENT, "2D Catmull-Rom Curve");
  1075.             DrawCatmullRomCurve (hdc, VL_TWOD);
  1076.             break;
  1077.         case IDM_3DCURVE_CATMULLROM:
  1078.             ViewerName (VL_CURRENT, "3D Catmull-Rom Curve");
  1079.             DrawCatmullRomCurve (hdc, VL_THREED);
  1080.             break;
  1081.         case IDM_2DCURVE_NURBS:
  1082.             ViewerName (VL_CURRENT, "2D Cubic and Quadratic NUBRS");
  1083.             DrawNURBSCurve (hdc, VL_TWOD);
  1084.             break;
  1085.         case IDM_3DCURVE_NURBS:
  1086.             ViewerName (VL_CURRENT, "3D Cubic and Quadratic NUBRS");
  1087.             DrawNURBSCurve (hdc, VL_THREED);
  1088.             break;
  1089.         case IDM_2DCURVE_QBEZIER:
  1090.             ViewerName (VL_CURRENT, "2D Quadratic Bezier Curve");
  1091.             DrawQuadraticCurve (hdc, VL_TWOD);
  1092.             break;
  1093.         case IDM_3DCURVE_QBEZIER:
  1094.             ViewerName (VL_CURRENT, "3D Quadratic Bezier Curve");
  1095.             DrawQuadraticCurve (hdc, VL_THREED);
  1096.             break;
  1097.         case IDM_3DSHAPE_ROSE:
  1098.             ViewerName (VL_CURRENT, "Roses in 3D");
  1099.             DrawRose (hdc, VL_THREED);
  1100.             break;
  1101.         case IDM_3DSHAPE_BOX:
  1102.             ViewerName (VL_CURRENT, "Rectangles in 3D");
  1103.             DrawBox (hdc, VL_THREED);
  1104.             break;
  1105.         case IDM_3DSHAPE_DISK:
  1106.             ViewerName (VL_CURRENT, "Disks in 3D");
  1107.             DrawDisk (hdc, VL_THREED);
  1108.             break;
  1109.         case IDM_3DSHAPE_NGON:
  1110.             ViewerName (VL_CURRENT, "Nside Polygons in 3D");
  1111.             DrawNgon (hdc, VL_THREED);
  1112.             break;
  1113.         case IDM_3DSHAPE_STAR:
  1114.             ViewerName (VL_CURRENT, "Nside Stars in 3D");
  1115.             DrawStar (hdc, VL_THREED);
  1116.             break;
  1117.         case IDM_3DSHAPE_FLOWER:
  1118.             DrawFlower (hdc, VL_THREED);
  1119.             ViewerName (VL_CURRENT, "Nside Flowers in 3D");
  1120.             break;
  1121.         case IDM_3DSHAPE_CHORD:
  1122.             ViewerName (VL_CURRENT, "Chords in 3D");
  1123.             DrawChord (hdc, VL_THREED);
  1124.             break;
  1125.         case IDM_3DSHAPE_PIE:
  1126.             ViewerName (VL_CURRENT, "Pies in 3D");
  1127.             DrawPie (hdc, VL_THREED);
  1128.             break;
  1129.         case IDM_3DSHAPE_RING:
  1130.             ViewerName (VL_CURRENT, "Rings in 3D");
  1131.             DrawRing (hdc, VL_THREED);
  1132.             break;
  1133.         case IDM_2DSHAPE_ROSE:
  1134.             ViewerName (VL_CURRENT, "Roses in 2D");
  1135.             DrawRose (hdc, VL_TWOD);
  1136.             break;
  1137.         case IDM_2DSHAPE_BOX:
  1138.             ViewerName (VL_CURRENT, "Rectangles in 2D");
  1139.             DrawBox (hdc, VL_TWOD);
  1140.             break;
  1141.         case IDM_2DSHAPE_DISK:
  1142.             ViewerName (VL_CURRENT, "Disks in 2D");
  1143.             DrawDisk (hdc, VL_TWOD);
  1144.             break;
  1145.         case IDM_2DSHAPE_NGON:
  1146.             ViewerName (VL_CURRENT, "Nside Polygons in 2D");
  1147.             DrawNgon (hdc, VL_TWOD);
  1148.             break;
  1149.         case IDM_2DSHAPE_STAR:
  1150.             ViewerName (VL_CURRENT, "Nside Stars in 2D");
  1151.             DrawStar (hdc, VL_TWOD);
  1152.             break;
  1153.         case IDM_2DSHAPE_FLOWER:
  1154.             ViewerName (VL_CURRENT, "Nside Flowers in 2D");
  1155.             DrawFlower (hdc, VL_TWOD);
  1156.             break;
  1157.         case IDM_2DSHAPE_CHORD:
  1158.             ViewerName (VL_CURRENT, "Chords in 2D");
  1159.             DrawChord (hdc, VL_TWOD);
  1160.             break;
  1161.         case IDM_2DSHAPE_PIE:
  1162.             ViewerName (VL_CURRENT, "Pies in 2D");
  1163.             DrawPie (hdc, VL_TWOD);
  1164.             break;
  1165.         case IDM_2DSHAPE_RING:
  1166.             ViewerName (VL_CURRENT, "Rings in 2D");
  1167.             DrawRing (hdc, VL_TWOD);
  1168.             break;
  1169.     }
  1170. }
  1171.  
  1172. VOIDED    Primitives2D (HDC hdc, WORD cmd)
  1173. {
  1174.     SelectPrimitives (hdc, cmd);
  1175. }
  1176.  
  1177. VOIDED    Primitives3D (HDC hdc, WORD cmd)
  1178. {
  1179.     PushTransformation3D (NULL);
  1180.     Scale3D (3, 3, 3);
  1181.     MarkPosition3D (hdc, 0, 0, 0, 10, VL_ORIGIN);
  1182.  
  1183.     PushTransformation3D (NULL);
  1184.     Translate3D (10, 8, 0);
  1185.     SelectPrimitives (hdc, cmd);
  1186.     PopTransformation3D (NULL);
  1187.     PushTransformation3D (NULL);
  1188.     Rotate3D (90, 'x');
  1189.     Translate3D (10, 8, 0);
  1190.     SelectPrimitives (hdc, cmd);
  1191.     PopTransformation3D (NULL);
  1192.     PushTransformation3D (NULL);
  1193.     Rotate3D (-90, 'y');
  1194.     Translate3D (10, 8, 0);
  1195.     SelectPrimitives (hdc, cmd);
  1196.     PopTransformation3D (NULL);
  1197.     PopTransformation3D (NULL);
  1198. }
  1199.  
  1200. BOOLEAN    BiArrayBox (HDC hdc, UINT row, UINT col)
  1201. {
  1202.     switch (row % 4) {
  1203.         case 0:
  1204.             SelectMaterial (VL_DEFAULT);
  1205.             break;
  1206.         case 1:
  1207.             SelectMaterial (mater1);
  1208.             break;
  1209.         case 2:
  1210.             SelectMaterial (mater2);
  1211.             break;
  1212.         case 3:
  1213.             SelectMaterial (mater3);
  1214.             break;
  1215.     }
  1216.     return (Cube (hdc, 2, 3, 4));
  1217. }
  1218.  
  1219. BOOLEAN    TriArrayBox (HDC hdc, UINT row, UINT col, UINT lev)
  1220. {
  1221.     switch (lev % 4) {
  1222.         case 0:
  1223.             SelectMaterial (VL_DEFAULT);
  1224.             break;
  1225.         case 1:
  1226.             SelectMaterial (mater1);
  1227.             break;
  1228.         case 2:
  1229.             SelectMaterial (mater2);
  1230.             break;
  1231.         case 3:
  1232.             SelectMaterial (mater3);
  1233.             break;
  1234.     }
  1235.     return (Cube (hdc, 2, 3, 2));
  1236. }
  1237.  
  1238. VOIDED    ObjectArray3D (HDC hdc, WORD func)
  1239. {
  1240.     ClearDepthBuffer (0xffff);
  1241.     switch (func) {
  1242.         case IDM_3DARRAY_RECTANGLE:
  1243.             RectangularArray3D (hdc, 4, 6, 8, 8,
  1244.                 (BidimArrayProc)MakeProcInstance (BiArrayBox, hinst));
  1245.             ViewerName (VL_CURRENT, "4x6 Rectangular Object Array");
  1246.             break;
  1247.         case IDM_3DARRAY_POLAR:
  1248.             PolarArray3D (hdc, 4, 6, 10, 30, 5,
  1249.                 (BidimArrayProc)MakeProcInstance (BiArrayBox, hinst));
  1250.             ViewerName (VL_CURRENT, "4x6 Polar Object Array");
  1251.             break;
  1252.         case IDM_3DARRAY_CUBIC:
  1253.             CubicArray (hdc, 4, 6, 5, 8, 8, 4,
  1254.                 (TridimArrayProc)MakeProcInstance(TriArrayBox, hinst));
  1255.             ViewerName (VL_CURRENT, "4x6x5 Cubic Object Array");
  1256.             break;
  1257.         case IDM_3DARRAY_CYLINDRIC:
  1258.             CylindricArray (hdc, 4, 6, 5, 10, 30, 5, 5,
  1259.                 (TridimArrayProc)MakeProcInstance (TriArrayBox, hinst));
  1260.             ViewerName (VL_CURRENT, "4x6x5 Cylindric Object Array");
  1261.             break;
  1262.         case IDM_3DARRAY_SPHERIC:
  1263.             SphericArray (hdc, 4, 6, 5, 10, 30, 30, 10, 30,
  1264.                 (TridimArrayProc)MakeProcInstance (TriArrayBox, hinst));
  1265.             ViewerName (VL_CURRENT, "4x6x5 Spheric Object Array");
  1266.             break;
  1267.     }
  1268. }
  1269.  
  1270. BOOLEAN    RectangularArray2DProc (HDC hdc, UINT row, UINT col)
  1271. {
  1272.     UINT    index;
  1273.  
  1274.     index = (row * 6 + col) % 8;
  1275.     BrushColor (hdc, index);
  1276.     Ngon2D (hdc, 0, 0, 0, 1, 1, index + 3);
  1277.     return (TRUE);
  1278. }
  1279.  
  1280. BOOLEAN    PolarArray2DProc (HDC hdc, UINT row, UINT col)
  1281. {
  1282.     BrushColor (hdc, row * 3 + col + 1);
  1283.     switch (col % 3) {
  1284.         case 0:
  1285.             Ngon2D (hdc, 0, 0, 0, 1, 1, row + 3);
  1286.             break;
  1287.         case 1:
  1288.             Star2D (hdc, 0, 0, 0, 1, 1, row + 3);
  1289.             break;
  1290.         case 2:
  1291.             Flower2D (hdc, 0, 0, 0, 1, 1, row + 3, 2);
  1292.             break;
  1293.     }
  1294.     return (TRUE);
  1295. }
  1296.  
  1297. VOIDED    ObjectArray2D(HDC hdc, WORD func)
  1298. {
  1299.     switch (func) {
  1300.         case IDM_2DARRAY_RECTANGLE:
  1301.             ViewerName (VL_CURRENT, "4x6 Rectangular Object Array");
  1302.             Translate2D (-8, -5);
  1303.             RectangularArray2D (hdc, 4, 6, 3, 3,
  1304.                 (BidimArrayProc)MakeProcInstance (RectangularArray2DProc, hinst));
  1305.             break;
  1306.         case IDM_2DARRAY_POLAR:
  1307.             PolarArray2D (hdc, 12, 3, 2, 30, 2,
  1308.                 (BidimArrayProc)MakeProcInstance (PolarArray2DProc, hinst));
  1309.             ViewerName (VL_CURRENT, "4x6 Polar Object Array");
  1310.             break;
  1311.     }
  1312. }
  1313.  
  1314. BOOLEAN    USFlag (HDC hdc)
  1315. {
  1316.     UINT    i, j;
  1317.     REAL    x1, y1, x2, y2, r, width, height;
  1318.  
  1319.     width = 1;
  1320.     height = (REAL) 13 / 24;
  1321.     x1 = 0;
  1322.     x2 = width;
  1323.     y1 = 0;
  1324.     y2 = height / 13;
  1325.     BrushColor (hdc, VL_RED);
  1326.     PenColor (hdc, VL_RED);
  1327.     for (i = 0; i < 7; i ++) {
  1328.         Rectangle2D (hdc, x1, y1, x2, y2);
  1329.         y1 += height * 2 / 13;
  1330.         y2 += height * 2 / 13;
  1331.     }
  1332.  
  1333.     BrushColor (hdc, VL_WHITE);
  1334.     PenColor (hdc, VL_WHITE);
  1335.     y1 = height / 13;
  1336.     y2 = height * 2 / 13 - 0.001f;
  1337.     for (i = 0; i < 6; i ++) {
  1338.         Rectangle2D (hdc, x1, y1, x2, y2);
  1339.         y1 += height * 2 / 13;
  1340.         y2 += height * 2 / 13;
  1341.     }
  1342.  
  1343.     BrushColor (hdc, VL_BLUE);
  1344.     PenColor (hdc, VL_BLUE);
  1345.     x2 = 10 * width / 24;
  1346.     y1 = 6 * height / 13;
  1347.     y2 = height;
  1348.     Rectangle2D (hdc, x1, y1, x2, y2);
  1349.  
  1350.     BrushColor (hdc, VL_WHITE);
  1351.     PenColor (hdc, VL_WHITE);
  1352.     x2 /= 6;
  1353.     x1 = x2 / 2;
  1354.     y2 = height * 7 / 13 / 5;
  1355.     r = 0.01f;
  1356.     for (i = 0; i < 6 ; i ++) {
  1357.         y1 = height - y2 / 2;
  1358.         for (j = 0; j < 5; j ++) {
  1359.             Star2D (hdc, x1, y1, 0, r, r, 5);
  1360.             y1 -= y2;
  1361.         }
  1362.         x1 = x1 + x2;
  1363.     }
  1364.     x1 = x2;
  1365.     for (i = 0; i < 5; i ++) {
  1366.         y1 = height - y2;
  1367.         for (j = 0; j < 4; j ++) {
  1368.             Star2D (hdc, x1, y1, 0, r, r, 5);
  1369.             y1 -= y2;
  1370.         }
  1371.         x1 = x1 + x2;
  1372.     }
  1373.     return (TRUE);
  1374. }
  1375.  
  1376. VOIDED    ModelPrimitives (HDC hdc, int func)
  1377. {
  1378.     HBODY    hb;
  1379.  
  1380.     switch (func) {
  1381.         case IDM_MODEL_BOX:
  1382.             hb = NewBox (40, 30, 20);
  1383.             ViewerName (VL_CURRENT, "Block Model");
  1384.             break;
  1385.         case IDM_MODEL_FRUSTUM:
  1386.             hb = NewFrustum (30, 20, 20, 10, 10);
  1387.             ViewerName (VL_CURRENT, "Frustum Model");
  1388.             break;
  1389.         case IDM_MODEL_SPHERE:
  1390.             hb = NewSphere (20, 24);
  1391.             ViewerName (VL_CURRENT, "Sphere Model");
  1392.             break;
  1393.         case IDM_MODEL_SOCCER:
  1394.             hb = NewBall (20);
  1395.             ViewerName (VL_CURRENT, "Soccer Ball Model");
  1396.             break;
  1397.         case IDM_MODEL_PYRAMID:
  1398.             hb = NewPyramid (30, 20, 0, 0, 30);
  1399.             ViewerName (VL_CURRENT, "Pyramid Model");
  1400.             break;
  1401.         case IDM_MODEL_CYLINDER:
  1402.             hb = NewCylinder (20, 30, 16);
  1403.             ViewerName (VL_CURRENT, "Cylinder Model");
  1404.             break;
  1405.         case IDM_MODEL_CONE:
  1406.             hb = NewCone (20, 30, 16);
  1407.             ViewerName (VL_CURRENT, "Cone Model");
  1408.             break;
  1409.         case IDM_MODEL_DOME:
  1410.             hb = NewDome (20, 30, 16);
  1411.             ViewerName (VL_CURRENT, "Tube Model");
  1412.             break;
  1413.         case IDM_MODEL_TUBE:
  1414.             hb = NewTube (20, 2, 30, 16);
  1415.             ViewerName (VL_CURRENT, "Tube Model");
  1416.             break;
  1417.         case IDM_MODEL_TORUS:
  1418.             hb = NewTorus (30, 5, 16, 8);
  1419.             ViewerName (VL_CURRENT, "Torus Model");
  1420.             break;
  1421.         case IDM_MODEL_REDUCER:
  1422.             break;
  1423.         case IDM_MODEL_REVOLVE:
  1424.         {
  1425.             POINT3D    profile[10];
  1426.             UINT    i;
  1427.  
  1428.             StarVertex (VL_3D, 30, 0, 0, 10, 10, 5, (LPREAL)profile);
  1429.             for (i = 0; i < 10; i++) {
  1430.                 profile[i].z = profile[i].y;
  1431.                 profile[i].y = 0;
  1432.             }
  1433.             hb = NewRevolution (profile, 10, 12, TWOPI);
  1434.             break;
  1435.         }
  1436.         case IDM_MODEL_SWEEP:
  1437.         {
  1438.             POINT3D    profile[10], path[4];
  1439.             REAL    scale[] = {1, 1, 1, 1};
  1440.  
  1441.             StarVertex (VL_3D, 0, 0, 0, 10, 10, 5, (LPREAL)profile);
  1442.             
  1443.             SetPoint3D (&path[0], 0, 0, 0);
  1444.             SetPoint3D (&path[1], 0, 0, 30);
  1445.             SetPoint3D (&path[2], 0, 30, 30);
  1446.             SetPoint3D (&path[3], 0, 30, 0);
  1447.             hb = NewSweep (profile, 10, path, scale, 2, TRUE);
  1448.             break;
  1449.         }
  1450.         case IDM_MODEL_EXTRUDE:
  1451.             break;
  1452.         case IDM_MODEL_PRISM:
  1453.         {
  1454.             POINT3D    vertex[10];
  1455.  
  1456.             StarVertex (VL_3D, 0, 0, 0, 40, 40, 5, (LPREAL)vertex);
  1457.             hb = NewPrismoid (vertex, 10, 0.7, -5, 5, 30);
  1458.             break;
  1459.         }
  1460.     }
  1461.     if (hb) {
  1462.         BodyShade (hdc, hb);
  1463.         FreeBody (hb);
  1464.     }
  1465. }
  1466.  
  1467. VOIDED    BooleanOperator (HDC hdc, int func)
  1468. {
  1469.     HBODY    b1 = 0, b2 = 0, b3 = 0;
  1470.  
  1471.     switch (func) {
  1472.         case IDM_BOOL_UNIONBOXES:
  1473.             b1 = NewBox (20, 30, 20);
  1474.             TranslateBody (b1, 5, -5, 0);
  1475.             b2 = NewBox (30, 20, 30);
  1476.             TranslateBody (b2, -5, 5, 0);
  1477.             b3 = UniteBody (b1, b2);
  1478.             ViewerName (VL_CURRENT, "Unionize Boxes");
  1479.             break;
  1480.         case IDM_BOOL_UNIONSPHERES:
  1481.             b1 = NewSphere (30, 24);
  1482.             b2 = NewSphere (20, 24);
  1483.             TranslateBody (b2, 0, 0, 20);
  1484.             b3 = UniteBody (b1, b2);
  1485.             ViewerName (VL_CURRENT, "Unionize Spheres");
  1486.             break;
  1487.         case IDM_BOOL_INTERBOXES:
  1488.             b1 = NewBox (20, 30, 20);
  1489.             TranslateBody (b1, 5, -5, 0);
  1490.             b2 = NewBox (30, 20, 30);
  1491.             TranslateBody (b2, -5, 5, 0);
  1492.             b3 = IntersectBody (b1, b2);
  1493.             ViewerName (VL_CURRENT, "Intersect Boxes");
  1494.             break;
  1495.         case IDM_BOOL_INTERSPHERES:
  1496.             b1 = NewSphere (30, 24);
  1497.             b2 = NewSphere (20, 24);
  1498.             TranslateBody (b2, 0, 30, 0);
  1499.             b3 = IntersectBody (b1, b2);
  1500.             ViewerName (VL_CURRENT, "Intersect Spheres");
  1501.             break;
  1502.         case IDM_BOOL_DIFFBOXES:
  1503.             b1 = NewBox (30, 30, 20);
  1504.             b2 = NewBox (20, 40, 30);
  1505.             b3 = SubtractBody (b1, b2);
  1506.             FreeBody (b1);
  1507.             FreeBody (b2);
  1508.             b1 = b3;
  1509.             b2 = NewBox (40, 20, 30);
  1510.             b3 = SubtractBody (b1, b2);
  1511.             ViewerName (VL_CURRENT, "Subtract A Box From Another");
  1512.             break;
  1513.         case IDM_BOOL_DIFFSPHERES:
  1514.             b1 = NewSphere (30, 24);
  1515.             b2 = NewSphere (20, 24);
  1516.             TranslateBody (b2, 0, 30, 0);
  1517.             b3 = SubtractBody (b1, b2);
  1518.             ViewerName (VL_CURRENT, "Subtract A Sphere From Another");
  1519.             break;
  1520.     }
  1521.     BodyShade (hdc, b3);
  1522.     FreeBody (b1);
  1523.     FreeBody (b2);
  1524.     FreeBody (b3);
  1525. }
  1526.  
  1527. VOIDED    BodyOperation (HDC hdc, int func)
  1528. {
  1529.     HBODY    b1, b2, b3, body[3];
  1530.     POINT3D    p;
  1531.     BASE    base;
  1532.     LINE    line;
  1533.     PLANE    plane;
  1534.     UINT    i, nb;
  1535.  
  1536.     switch (func) {
  1537.         case IDM_TOOL_DRILL:
  1538.             b1 = NewBox (30, 30, 40);
  1539.             VSET3 (line.v, 1, -1, 0);
  1540.             VSET3 (line.p, 0, 20, 10);
  1541.             b2 = DrillBody (b1, &line, 2, ALL_WAY);
  1542.             FreeBody (b1);
  1543.             VSET3 (base.origin, 0, 20, 30);
  1544.             VSET3 (base.zvect, 1, -1, 0);
  1545.             VSET3 (base.xvect, 0, 0, 1);
  1546.             b1 = b2;
  1547.             b2 = MortiseBody (b1, &base, 3, 7, THROUGH);
  1548.             FreeBody (b1);
  1549.             VSET3 (plane.n, 0, 0, 1);
  1550.             plane.e = -20;
  1551.             nb = SplitBody (b2, &plane, body);
  1552.             FreeBody (b2);
  1553.             for (i = 0; i < nb; i++) {
  1554.                 BodyShade (hdc, body[i]);
  1555.                 FreeBody (body[i]);
  1556.                 Translate3D (-5, 5, 0);
  1557.             }
  1558.             break;
  1559.         case IDM_TOOL_MORTISE:
  1560.             b1 = NewBox (50, 40, 30);
  1561.             VSET3 (plane.n, 1, 1, 0);
  1562.             plane.e = 0;
  1563.             SetPoint3D (&p, 25, 20, 20);
  1564.             b2 = CutThroughBody (b1, &plane, &p);
  1565.             BodyShade (hdc, b2);
  1566.             FreeBody (b1);
  1567.             FreeBody (b2);
  1568.             break;
  1569.         case IDM_TOOL_CUT:
  1570.             b1 = NewBox (50, 40, 30);
  1571.             VSET3 (line.v, 0, -1, 0);
  1572.             VSET3 (line.p, -20, 30, 20);
  1573.             b2 = DrillBody (b1, &line, 2, ALL_WAY);
  1574.             FreeBody (b1);
  1575.             VSET3 (line.p, -10, 30, 15);
  1576.             b1 = DrillBody (b2, &line, 5, ALL_WAY);
  1577.             FreeBody (b2);
  1578.             VSET3 (line.p, 10, 30, 15);
  1579.             b2 = DrillBody (b1, &line, 5, ALL_WAY);
  1580.             FreeBody (b1);
  1581.             VSET3 (line.p, 20, 30, 20);
  1582.             b1 = DrillBody (b2, &line, 5, ALL_WAY);
  1583.             FreeBody (b2);
  1584.             VSET3 (line.v, -1, 0, 0);
  1585.             VSET3 (line.p, 30, -10, 15);
  1586.             b2 = DrillBody (b1, &line, 5, ALL_WAY);
  1587.             FreeBody (b1);
  1588.             VSET3 (line.p, 30, 10, 15);
  1589.             b1 = DrillBody (b2, &line, 5, ALL_WAY);
  1590.             FreeBody (b2);
  1591.  
  1592.             VSET3 (plane.n, 0, 0, 1);
  1593.             plane.e = -15;
  1594.  
  1595.             nb = SplitBody (b1, &plane, body);
  1596.             FreeBody (b1);
  1597.             b2 = body[0];
  1598.             b1 = body[1];
  1599.             TranslateBody (b2, 0, 30, 0);
  1600.             BodyShade (hdc, b2);
  1601.             VSET3 (line.p, 0, -10, 0);
  1602.             VSET3 (line.v, 1, 0, 0);
  1603.             RotateBody (b1, &line, HALFPI);
  1604.             BodyShade (hdc, b1);
  1605.             FreeBody (b1);
  1606.             FreeBody (b2);
  1607.  
  1608.             break;
  1609.         case IDM_TOOL_SPLIT:
  1610.             b1 = NewBox (30, 30, 40);
  1611.             VSET3 (plane.n, 0.707, 0.707, 0);
  1612.             plane.e = 0;
  1613.             nb = SplitBody (b1, &plane, body);
  1614.             for (i = 0; i < nb; i++) {
  1615.                 BodyShade (hdc, body[i]);
  1616.                 FreeBody (body[i]);
  1617.                 Translate3D (-5, 5, 0);
  1618.             }
  1619.             break;
  1620.         case IDM_TOOL_CHAMFER:
  1621.             b1 = NewBox (30, 30, 40);
  1622.  
  1623.             SetPoint3D (&p, 0, 0, 40);
  1624.             b2 = ChamferBodyFace (b1, PickBodyFace (b1, &p), 2);
  1625.             FreeBody (b1);
  1626.  
  1627.             SetPoint3D (&p, 15, 15, 38);
  1628.             b1 = ChamferBodyVert (b2, PickBodyVert (b2, &p), 3);
  1629.             FreeBody (b2);
  1630.  
  1631.             SetPoint3D (&p, 15, 15, 20);
  1632.             b2 = ChamferBodyEdge (b1, PickBodyEdge (b1, &p), 2);
  1633.             FreeBody (b1);
  1634.  
  1635.             BodyShade (hdc, b2);
  1636.             FreeBody (b2);
  1637.             break;
  1638.         case IDM_TOOL_SLICE:
  1639.             b1 = NewBox (50, 40, 30);
  1640.             VSET3 (line.v, 0, -1, 0);
  1641.             VSET3 (line.p, -20, 30, 20);
  1642.             b2 = DrillBody (b1, &line, 2, ALL_WAY);
  1643.             FreeBody (b1);
  1644.             VSET3 (line.p, -10, 30, 15);
  1645.             b1 = DrillBody (b2, &line, 5, ALL_WAY);
  1646.             FreeBody (b2);
  1647.             VSET3 (line.p, 10, 30, 15);
  1648.             b2 = DrillBody (b1, &line, 5, ALL_WAY);
  1649.             FreeBody (b1);
  1650.             VSET3 (line.p, 20, 30, 20);
  1651.             b1 = DrillBody (b2, &line, 5, ALL_WAY);
  1652.             FreeBody (b2);
  1653.             VSET3 (line.v, -1, 0, 0);
  1654.             VSET3 (line.p, 30, -10, 15);
  1655.             b2 = DrillBody (b1, &line, 5, ALL_WAY);
  1656.             FreeBody (b1);
  1657.             VSET3 (line.p, 30, 10, 15);
  1658.             b1 = DrillBody (b2, &line, 5, ALL_WAY);
  1659.             FreeBody (b2);
  1660.             VSET3 (plane.n, 1, 1, 0);
  1661.             plane.e = 0;
  1662.             b3 = SliceBody (b1, &plane);
  1663.             BodyShade (hdc, b3);
  1664.             FreeBody (b3);
  1665.             FreeBody (b1);
  1666.  
  1667.             break;
  1668.     }
  1669. }
  1670.  
  1671. VOIDED    ModellibDemo (HDC hdc, WORD func)
  1672. {
  1673.     BackFaceRemoval (TRUE);
  1674.     TwoSideShading (FALSE);
  1675.     ClearDepthBuffer (0xffff);
  1676.     if (func < 2020)
  1677.         ModelPrimitives (hdc, func);
  1678.     else if (func < 2030)
  1679.         BooleanOperator (hdc, func);
  1680.     else if (func < 2040)
  1681.         BodyOperation (hdc, func);
  1682.     CleanupMemory ();
  1683. }
  1684.